# Makefile for ispace project
.Phony: all install build nginx core rscMonitor_install desktop_install hyperlink_install fileTransfer_install openapi_install resource_manager_install text_editor_install DriveEngin_install windows_install front_install core_install front_build rscMonitor_build DriveEngin_build desktop_build hyperlink_build fileTransfer_build resource_manager_build text_editor_build windows_build openapi_build 

all: installWithSync build nginx core
	@echo "all done"

core: nginx
	cd /code/ispace/src/core && go run .

installWithSync:
	make -j install

install: rscMonitor_install openapi_install desktop_install hyperlink_install fileTransfer_install resource_manager_install text_editor_install DriveEngin_install windows_install front_install core_install
	@echo "install done"

build: rscMonitor_build core_build front_build DriveEngin_build openapi_build desktop_build hyperlink_build fileTransfer_build resource_manager_build text_editor_build windows_build
	@echo "build done"

nginx: /code/ispace/src/server/nginx/init.sh /code/ispace/src/server/nginx/config.sh
	@echo "nginx config"
	sh /code/ispace/src/server/nginx/init.sh
	sh /code/ispace/src/server/nginx/config.sh

## step 1：环境安装 

desktop_install:
	cd /code/ispace/src/app/desktop/front/desktop && npm install

hyperlink_install:
	cd /code/ispace/src/app/hyperlink/front/hyperlink && npm install

fileTransfer_install:
	cd /code/ispace/src/app/fileTransfer/front/fileTransfer && npm install

resource_manager_install:
	cd /code/ispace/src/app/resource-manager/front/resource-manager && npm install

text_editor_install:
	cd /code/ispace/src/app/text-editor/front/text-editor && npm install
rscMonitor_install:
	cd /code/ispace/src/cmnComp/rscMonitor && npm install

DriveEngin_install:
	cd /code/ispace/src/cmnComp/DriveEngin && npm install

windows_install:
	cd /code/ispace/src/cmnComp/windows && npm install

openapi_install:
	cd /code/ispace/src/cmnComp/desktopOpenApi && npm install

front_install:
	cd /code/ispace/src/core/front && npm install

core_install:
	cd /code/ispace/src/core && \
	if [ "$(ENV)" = "pro" ]; then \
		go mod download -x -json; \
	else \
		go mod tidy; \
	fi

## step 2：编译构建
front_build:
	cd /code/ispace/src/core/front && npm run link  && npm run build && npm link

rscMonitor_build:
	cd /code/ispace/src/cmnComp/rscMonitor && npm run build && npm link

DriveEngin_build:
	cd /code/ispace/src/cmnComp/DriveEngin && npm run build && npm link

openapi_build:
	cd /code/ispace/src/cmnComp/desktopOpenApi && npm run build && npm link

desktop_build:
	cd /code/ispace/src/app/desktop/front/desktop && npm run link && npm run build

hyperlink_build:
	cd /code/ispace/src/app/hyperlink/front/hyperlink && npm run link && npm run build

fileTransfer_build:
	cd /code/ispace/src/app/fileTransfer/front/fileTransfer && npm run link && npm run build

resource_manager_build:
	cd /code/ispace/src/app/resource-manager/front/resource-manager && npm run link && npm run build

text_editor_build:
	cd /code/ispace/src/app/text-editor/front/text-editor && npm run link && npm run build

windows_build:
	cd /code/ispace/src/cmnComp/windows && npm run build

core_build: front_build
	cd /code/ispace/src/core && go build -o /code/ispace/src/core/publish/core && mkdir -p publish/front/ && cp -rf front/dist front/examples front/public front/src publish/front/
